package com.siki.vo;

import com.siki.pojo.enumerate.DepartmentPosition;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@ApiModel("部门职位信息VO")
@Getter
@Setter
@NoArgsConstructor
public class EnumRoleVO {

    @ApiModelProperty("位置信息")
    String department;

    @ApiModelProperty("下位信息")
    List<EnumRoleVO> position;

    public EnumRoleVO(DepartmentPosition departmentPosition){
        this.department = departmentPosition.toString();
        this.position = getPosition(departmentPosition);
    }

    public static List<EnumRoleVO> EnumRoleVOList(List<DepartmentPosition> departmentPositions){
        List<EnumRoleVO> enumRoleVOS = new ArrayList<>();
        for (DepartmentPosition dp :
                departmentPositions) {
            enumRoleVOS.add(new EnumRoleVO(dp));
        }
        return enumRoleVOS;
    }

    public List<EnumRoleVO> getPosition(DepartmentPosition departmentPosition){
        return DepartmentPosition.getPosition(departmentPosition).stream().map(EnumRoleVO::new).collect(Collectors.toList());
    }
}
